﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TMS_Master.DTO.Personnel;
using TMS_Master.Personnel_module;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Repositories;

namespace TMS_Master
{
    public class QuitService : CrudAppService
        <Quit,
        QuitDTO,
        Guid,
        PagedAndSortedResultRequestDto,
        QuitDTOText>,
        IQuitService
    {
        public readonly IRepository<Quit, Guid> tMSApp;
        public QuitService(IRepository<Quit, Guid> _tMSApp) : base(_tMSApp)
        {
            tMSApp = _tMSApp;
        }
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="Staff"></param>
        /// <returns></returns>
        public async Task<int> AddQuit(QuitDTO Quit)
        {
            Quit Add = ObjectMapper.Map<QuitDTO, Quit>(Quit);
            await tMSApp.InsertAsync(Add);
            return 1;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task DelQuit(Guid Id)
        {
            await tMSApp.DeleteAsync(Id);
        }
        /// <summary>
        /// 反填
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task<QuitDTO> FanQuit(Guid Id)
        {
            Quit b = await tMSApp.GetAsync(Id);
            QuitDTO fan = ObjectMapper.Map<Quit, QuitDTO>(b);
            return fan;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <returns></returns>
        public async Task<List<QuitDTO>> GetQuit()
        {
            List<Quit> p = await tMSApp.ToListAsync();
            List<Quit> Quit = p;
            List<QuitDTO> QuitDTOs = ObjectMapper.Map<List<Quit>, List<QuitDTO>>(Quit);
            return QuitDTOs;

        }
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="become"></param>
        /// <returns></returns>
        public async Task<int> UptQuit(QuitDTO quit)
        {
            Quit e = await tMSApp.GetAsync(quit.Id);
            e.QuitName = quit.QuitName;
            return 1;
        }
    }
}
